<!-- 搜索表单 -->
<template>
    <el-card shadow="never" >
      <el-form
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="search"
        @submit.native.prevent
      >
        <el-row :gutter="24">
          <el-col :lg="5" :md="24">
            <el-form-item label="关键字:">
              <el-input clearable v-model="where.keyword" placeholder="支持产品编号、名称糊查询" />
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <el-form-item label="产品类型:">
              <el-select v-model="where.productTypeId" clearable placeholder="请输入产品类型">
                <el-option v-for="(item, index) in productTypeDatas" :key="index" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :lg="7" :md="24">
            <el-form-item label="过账日期:">
              <el-date-picker v-model="where.modifyDate" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="daterange"
                  range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="24" >
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="search"
              >
                查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    </template>
   
    <script>
      const DEFAULT_WHERE = {
        keyword: '',    //关键字
        productTypeId:'',
        modifyDate:'',
      };
      import { QueryAllChildDictViewByCode } from '@/api/systemmanager/dictmanager';
      export default {
        name: 'PayaccountDetailSearch',
       
        data() {
          return {
            // 表单数据
            where: { ...DEFAULT_WHERE },
            productTypeDatas:[],
          };
        },
        //初始化数据
        created(){
          this.queryTypeEnums();
        },
    
        methods: {
    
          /* 搜索 */
          search() {
            let params = {
              pageindex: 1,
              conditions: {},
              orderBys: [{ sort: "createDate", order: 1, }],
          };

          //单据编号
          if(this.where.keyword){
            params.conditions.keyword = this.where.keyword;
          }

          if(this.where.productTypeId){
            params.conditions.productTypeId = this.where.productTypeId;
          }

          //单据日期
          if(this.where.modifyDate){
            params.conditions.sdate = this.where.modifyDate[0] + " 00:00:00";
            params.conditions.edate = this.where.modifyDate[1] + " 23:59:59";
          }

          this.$emit('search', params);

          },

          /*  重置 */
          reset() {
            this.where = { ...DEFAULT_WHERE };
            this.search();
          },

          /* 系统状态 */
          queryTypeEnums(){
            QueryAllChildDictViewByCode(this.Constant.C_CPLX).then((d)=>{
              this.productTypeDatas = [];
              this.productTypeDatas = d;
            });
          },
        }
      };
    </script>
    